<%@ page import="java.util.List" %>
<%@ page import="com.neusoft.student.model.Student" %>
<%@ page import="com.neusoft.student.utils.Pager" %><%--
  Created by IntelliJ IDEA.
  User: 86185
  Date: 2020/10/20
  Time: 16:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>主页面</title>
</head>
<body>
<table>
<%--    <jsp:include page="include/header.jsp"/>--%>
    <%@include file="include/header.jsp"%>
    <thead>
    <tr>
      <th>学号</th>
      <th>姓名</th>
      <th>性别</th>
      <th>宿舍楼</th>
      <th>寝室</th>
      <th>电话</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <%
      List<Student> list = (List<Student>) request.getAttribute("list");
      for (Student item : list) {
    %>
      <tr>
        <td><%=item.getId()%></td>
        <td><%=item.getUsername()%></td>
        <td><%=item.getSex()%></td>
        <td><%=item.getDormitory()%></td>
        <td><%=item.getId()%></td>
        <td><%=item.getPhone()%></td>
        <td><a href="studenttoedit?id=<%=item.getId()%>">编辑</a><a href="studentDelete?id=<%=item.getId()%>">删除</a></td>
      </tr>
    <%
      }
    %>
    </tbody>
</table>
<ul style="list-style: none;">
<%--    <li style="float: left;margin: 10px;"><a href="#">1</a></li>--%>
<%--    <li style="float: left;margin: 10px;"><a href="#">2</a></li>--%>
<%--    <li style="float: left;margin: 10px;"><a href="#">3</a></li>--%>
<%--    <li style="float: left;margin: 10px;"><a href="#">4</a></li>--%>
    <%
//        int count = (int) request.getAttribute("count");
//        int pageSize = (int) request.getAttribute("pageSize");
//        int pageNum = (int) request.getAttribute("pageNum");
//        int pageTotal = 0;
//        if (count <= pageSize) {
//            pageTotal = 1;
//        } else {
//            if (count % pageSize == 0) {
//                //整除
//                pageTotal = count / pageSize;
//            } else {
//                pageTotal = count / pageSize + 1;
//            }
//        }
//        System.out.println(count);
//        System.out.println(pageSize);
//        System.out.println(pageTotal);
        Pager pager = (Pager) request.getAttribute("pager");
        for (int i = 1; i <= pager.getPageTotal(); i++) {
            if (i == pager.getPageNum()) {
    %>
        <li style="float: left;margin: 10px;"><%=i%></li>
    <%
        } else {
    %>
        <li style="float: left;margin: 10px;"><a href="studentlist?pageNum=<%=i%>"><%=i%></a></li>
    <%
            }
        }
    %>
</ul>
<%--<script src="<%=pageContext.getServletContext().getContextPath()%>/js/jquery-3.5.1.js"></script>--%>
<%--<script src="<%=pageContext.getAttribute("basePath")%>/js/jquery-3.5.1.js"></script>--%>
<script src="<%=basePath%>/js/jquery-3.5.1.js"></script>
</body>
</html>
